import {all, put, take, call, fork, race} from 'redux-saga/effects';
import * as types from '../action-types'
import {delay} from '../utils'


//功能2：race 他会自动取消那些失败的effect

function* start() {
    while (true) {
        yield call(delay,1000)
        yield put({type:types.INCREMENT})
    }
}

export default function* () {
   yield race({
       start:call(start),
       stop:take(types.CANCEL_COUNTER)
   })

}
